home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / EDITSDI.PAK / GLOBALS.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  9KB  |  230 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. // PURPOSE:
  9. //    Contains declarations for all globally scoped names in the program.
  10. //
  11.  
  12. //-------------------------------------------------------------------------
  13. // Product identifier string defines
  14.  
  15. //  **TODO** Change these strings to the name of your application.
  16.  
  17. #define SZAPPNAME     "EditSDI"
  18. #define SZDESCRIPTION "SDI Editor Example Application"
  19.  
  20.  
  21. //-------------------------------------------------------------------------
  22. // Functions for handling main window messages.  The message-dispatching
  23. // mechanism expects all message-handling functions to have the following
  24. // prototype:
  25. //
  26. //     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
  27.  
  28. // **TODO**  Add message-handling function prototypes here.  Be sure to
  29. //           add the function names to the main window message table in
  30. //           editsdi.c.
  31.  
  32. LRESULT MsgCommand(HWND, UINT, WPARAM, LPARAM);             // Misc
  33. LRESULT MsgDestroy(HWND, UINT, WPARAM, LPARAM);
  34. LRESULT MsgSetFocus(HWND, UINT, WPARAM, LPARAM);
  35. LRESULT MsgSize(HWND, UINT, WPARAM, LPARAM);
  36. LRESULT MsgQueryEndSession(HWND, UINT, WPARAM, LPARAM);
  37. LRESULT MsgClose(HWND, UINT, WPARAM, LPARAM);
  38. LRESULT MsgInitMenu(HWND, UINT, WPARAM, LPARAM);
  39. LRESULT MsgFindReplace(HWND, UINT, WPARAM, LPARAM);         // Search
  40.  
  41. //-------------------------------------------------------------------------
  42. // Functions for handling main window commands--ie. functions for
  43. // processing WM_COMMAND messages based on the wParam value.
  44. // The message-dispatching mechanism expects all command-handling
  45. // functions to have the following prototype:
  46. //
  47. //     LRESULT FunctionName(HWND, WORD, WORD, HWND);
  48.  
  49. // **TODO**  Add message-handling function prototypes here.  Be sure to
  50. //           add the function names to the main window command table in
  51. //           editsdi.c.
  52.  
  53. LRESULT CmdExit(HWND, WORD, WORD, HWND);                    // Misc.
  54. LRESULT CmdAbout(HWND, WORD, WORD, HWND);
  55. LRESULT CmdClip(HWND, WORD, WORD, HWND);                    // Clipboard
  56. LRESULT CmdFileNew(HWND, WORD, WORD, HWND);                 // File
  57. LRESULT CmdFileOpen(HWND, WORD, WORD, HWND);
  58. LRESULT CmdFileSave(HWND, WORD, WORD, HWND);
  59. LRESULT CmdFileSaveAs(HWND, WORD, WORD, HWND);
  60. LRESULT CmdPrint(HWND, WORD, WORD, HWND);                   // Print
  61. LRESULT CmdPrintSU(HWND, WORD, WORD, HWND);
  62. LRESULT CmdEdit(HWND, WORD, WORD, HWND);                    // Edit
  63. LRESULT CmdFindReplace(HWND, WORD, WORD, HWND);             // Search
  64. LRESULT CmdFindNext(HWND, WORD, WORD, HWND);
  65.  
  66. //-------------------------------------------------------------------------
  67. // Global type declarations.
  68.  
  69. typedef enum {
  70.     frtFind,
  71.     frtReplace,
  72.     frtRepAll
  73. } FRT;  // Find/Replace tag
  74.  
  75.  
  76. //-------------------------------------------------------------------------
  77. // Global function prototypes.
  78.  
  79. // **TODO**  Add global function prototypes here.
  80.  
  81. BOOL InitApplication(HINSTANCE);                            // Misc
  82. BOOL InitInstance(HINSTANCE, int);
  83. BOOL CenterWindow(HWND, HWND);
  84. VOID Open(LPSTR, BOOL, HWND);                               // File
  85. VOID SaveAs(LPSTR, HWND);
  86. BOOL QuerySaveFile(HWND);
  87. VOID Print                                                  // Print
  88.     (HWND, HDC, BOOL, BOOL, BOOL, BOOL, UINT, UINT, UINT, HGLOBAL);
  89. DWORD GetPageRange(VOID);
  90. BOOL InitEdit(HWND);
  91. VOID SetEditText(HWND, HANDLE);
  92. char *LockEditText(HWND);
  93. VOID UnlockEditText(HWND);
  94. BOOL InitFindReplace(VOID);                                 // Search
  95. BOOL IsFindReplaceMsg(LPMSG);
  96. BOOL CanFind(VOID);
  97. VOID FindReplace(char *, char *, FRT, BOOL, BOOL, BOOL);
  98.  
  99. extern char szFName[];
  100. extern HWND hwndEdit;
  101.  
  102. char *GetFName(VOID);
  103. HWND GetEditWindow(VOID);
  104.  
  105.  
  106.     // Callback functions.  These are called by Windows.
  107.  
  108. // **TODO**  Add new callback function prototypes here.  Win16 compiles
  109. //           require the __export keyword to generate proper prolog
  110. //           and epilog code for exported functions.
  111.  
  112. #ifdef WIN16
  113.  
  114. LRESULT CALLBACK __export WndProc(HWND, UINT, WPARAM, LPARAM);
  115.  
  116. #else
  117.  
  118. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  119.  
  120. #endif
  121.  
  122.  
  123. //-------------------------------------------------------------------------
  124. // Global macro definitions.
  125.  
  126.  
  127. #define MAKEBOOL(i) ((BOOL) !!(i))                          // General
  128. #ifdef WIN16
  129. #define GETSEL(ichS,ichE) \
  130.     { \
  131.         DWORD dwSel = SendMessage(GetEditWindow(), EM_GETSEL, 0, 0L); \
  132.         ichS = LOWORD(dwSel); \
  133.         ichE = HIWORD(dwSel); \
  134.     }
  135. #define SETSEL(ichS,ichE) \
  136.     SendMessage(GetEditWindow(), EM_SETSEL, FALSE, MAKELONG(ichS, ichE))
  137. #else
  138. #define GETSEL(ichS,ichE) \
  139.     SendMessage(GetEditWindow(), EM_GETSEL, (WPARAM) &ichS, (LPARAM) &ichE)
  140. #define SETSEL(ichS,ichE) \
  141.     SendMessage(GetEditWindow(), EM_SETSEL, (WPARAM) ichS, (LPARAM) ichE)
  142. #endif
  143.  
  144.  
  145. //-------------------------------------------------------------------------
  146. // Global variable declarations.
  147.  
  148. extern HINSTANCE hInst;          // The current instance handle
  149. extern HWND      hwndMain;       // Main application window
  150. extern char      szAppName[];    // The name of this application
  151. extern char      szTitle[];      // The title bar text
  152. extern HCURSOR hcursHourGlass;   // Hourglass cursor
  153.  
  154. // **TODO**  For NON-MDI applications, uncomment line 1 below and comment
  155. //           line 2.  For MDI applications, uncomment line 2 below, comment
  156. //           line 1, and then define hwndMDIClient as a global variable in
  157. //           INIT.C
  158. #define hwndMDIClient NULL        /* (1) Stub for NON-MDI applications. */
  159. // extern HWND hwndMDIClient;     /* (2) For MDI applications.          */
  160.  
  161.  
  162. //-------------------------------------------------------------------------
  163. // Message and command dispatch infrastructure.  The following type
  164. // definitions and functions are used by the message and command dispatching
  165. // mechanism and do not need to be changed.
  166.  
  167.     // Function pointer prototype for message handling functions.
  168. typedef LRESULT (*PFNMSG)(HWND,UINT,WPARAM,LPARAM);
  169.  
  170.     // Function pointer prototype for command handling functions.
  171. typedef LRESULT (*PFNCMD)(HWND,WORD,WORD,HWND);
  172.  
  173.     // Enumerated type used to determine which default window procedure
  174.     // should be called by the message- and command-dispatching mechanism
  175.     // if a message or command is not handled explicitly.
  176. typedef enum
  177. {
  178.    edwpNone,            // Do not call any default procedure.
  179.    edwpWindow,          // Call DefWindowProc.
  180.    edwpDialog,          // Call DefDlgProc (This should be used only for
  181.                         // custom dialogs - standard dialog use edwpNone).
  182.    edwpMDIChild,        // Call DefMDIChildProc.
  183.    edwpMDIFrame         // Call DefFrameProc.
  184. } EDWP;                // Enumeration for Default Window Procedures
  185.  
  186.     // This structure maps messages to message handling functions.
  187. typedef struct _MSD
  188. {
  189.     UINT   uMessage;
  190.     PFNMSG pfnmsg;
  191. } MSD;                 // MeSsage Dispatch structure
  192.  
  193.     // This structure contains all of the information that a window
  194.     // procedure passes to DispMessage in order to define the message
  195.     // dispatching behavior for the window.
  196. typedef struct _MSDI
  197. {
  198.     int  cmsd;          // Number of message dispatch structs in rgmsd
  199.     MSD *rgmsd;         // Table of message dispatch structures
  200.     EDWP edwp;          // Type of default window handler needed.
  201. } MSDI, FAR *LPMSDI;   // MeSsage Dipatch Information
  202.  
  203.     // This structure maps command IDs to command handling functions.
  204. typedef struct _CMD
  205. {
  206.     WORD   wCommand;
  207.     PFNCMD pfncmd;
  208. } CMD;                 // CoMmand Dispatch structure
  209.  
  210.     // This structure contains all of the information that a command
  211.     // message procedure passes to DispCommand in order to define the
  212.     // command dispatching behavior for the window.
  213. typedef struct _CMDI
  214. {
  215.     int  ccmd;          // Number of command dispatch structs in rgcmd
  216.     CMD *rgcmd;         // Table of command dispatch structures
  217.     EDWP edwp;          // Type of default window handler needed.
  218. } CMDI, FAR *LPCMDI;   // CoMmand Dispatch Information
  219.  
  220.     // Message and command dispatching functions.  They look up messages
  221.     // and commands in the dispatch tables and call the appropriate handler
  222.     // function.
  223. LRESULT DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM);
  224. LRESULT DispCommand(LPCMDI, HWND, WPARAM, LPARAM);
  225.  
  226.     // Message dispatch information for the main window
  227. extern MSDI msdiMain;
  228.     // Command dispatch information for the main window
  229. extern CMDI cmdiMain;
  230.